/** @jsxImportSource @emotion/react */
import * as React from "react";
import { OriginalViewProps, } from "../../common/base";
import {config设备概况, EntranceSetup} from "./orcBase";
import { createItem, } from "../../common/eHelper";
import { useRecordListSubr} from "../../hook/useRecordListSub";
import {PropertySolidify} from "../../industrial/EditorFeature";
import {SingleLineDiagram} from "../../industrial/editorLineDg";
import {IPipingUnitEntity} from "../../../comp/ChoosePipingUnits";
import {ConclusionLdisN, } from "./Conclusion";
import {ProjectListRq} from "../../vessel/editProj";
import {ConclusionSurvey} from "../plastics/Conclusion";
import {AppendixPage, AppendixPage2} from "./AppendixPage";
import {tail附页} from "./orcBase";

export const Projects默认=[
    {name:'长输管道年度检查结论报告',do:true,ha:'Conclusion'},
    //【固定配置】页面。
    {name:'年度检查报告附页',do:true,ha:'AppendixPage',na:true},
    //旧平台【都没有】相应模板的，    下面9个都未有模板的。 或用公用的模板？
    {name:'资料审查报告',ha:''},
    {name:'地面环境及设施检查报告',ha:''},
    {name:'防腐(保温)层检查报告',ha:''},
    {name:'电性能测试报告',ha:''},
    {name:'阴极保护系统测试报告',ha:''},
    {name:'壁厚测定报告',ha:''},
    {name:'地质条件调查报告',ha:''},
    {name:'安全附件与仪表检查报告',ha:''},
    {name:'管道特性表', do:true,ha:'Characteristics'},
    {name:'管道单线图', ha:'PipeLineDiagram',},
];

const recordPrintList =[
    createItem('Entrance', <EntranceSetup/>),
    createItem('ProjectList', <ProjectListRq config={Projects默认}  label={'目录页'}/>),
    createItem('Survey', <ConclusionSurvey config={config设备概况} label={'长输管道年度检查结论报告-设备概况'}/>),
    createItem('Conclusion', <ConclusionLdisN label={'长输管道年度检查结论报告-下结论'}/>),
    createItem('AppendixPage', <AppendixPage label={'长输管道年度检查报告附页（上）'} children={tail附页}/>),
    createItem('ApxIspItms_19', <AppendixPage2  label={'长输管道年度检查报告附页（下）'} children={tail附页}/>),
    createItem('Solidify', <PropertySolidify label={'管道特性表-管理器'} filterCB={modelToRepData}/>),
    createItem('LineDiagram', <SingleLineDiagram />),
    createItem('_Controller',  <></>),
];

//特性表不一样就得改了：
//针对这个模板CharacteristRow()需要显示字段： 从Relay模型获取报告才需要的字段：svp pa只保存有用到的字段：但是PropertySolidify必须提取全面useLazyLoadQuery<typeof EditorFeatureQuery>。
function modelToRepData(pipe:IPipingUnitEntity){
  const {id,crDate,name,code,leng,level,start,stop,lay,rno,svp,pa,proj,insd,used,}=pipe as any;
  const {材料,设压,设温, 腐蚀, 规格 }=svp;
  const {工介,工压,工温,试压,防腐材,沥青级,防腐厚}=pa;
  //节约存储; 后端报告中：不需要存储usue{id,name}；
  return {
    id,crDate, name,code,leng,level,start,stop,lay,rno,proj,insd,used,
    svp:{材料,设压,设温, 腐蚀, 规格 },
    pa:{工介,工压,工温,试压,防腐材,沥青级,防腐厚}
  };
}

export const OriginalView=
  React.forwardRef((
    { action: modAction,  verId, repId='', rep}
    :OriginalViewProps, ref
  ) => {
    const {list}=useRecordListSubr(ref,rep,recordPrintList,modAction,verId);
    return <React.Fragment>
      {list}
    </React.Fragment>;
  } );
